package logic

import (
	"context"
	"wechat/models/mysql"
	"wechat/wechatrpc/internal/svc"
	"wechat/wechatrpc/wechatrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type WeMomentsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewWeMomentsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WeMomentsLogic {
	return &WeMomentsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 发布朋友圈
func (l *WeMomentsLogic) WeMoments(in *wechatrpc.WeMomentsRequest) (*wechatrpc.WeMomentsResponse, error) {
	// todo: add your logic here and delete this line

	moments := mysql.WechatMoments{
		Context: in.Context,
		UserId:  in.UserId,
	}

	mysql.DB.Debug().Create(&moments)

	return &wechatrpc.WeMomentsResponse{
		Id: int64(moments.ID),
	}, nil
}
